<?php

class Back_Form_Groupes extends Jnd_Form
{
    protected $_utilisateurs = array();
    protected $_roles = array();

    public function __construct ($decorateur = "Formulairejndpro", $options = null)
    {
        if (isset($options["utilisateurs"])) {
            $this->_utilisateurs = $options['utilisateurs'];
        }
        if (isset($options["roles"])) {
            $this->_roles = $options['roles'];
        }
        parent::__construct($decorateur, $options);
        $this->setElementDecorators(
                array(
                        "$decorateur"
                ), array(), false);
    }

    public function init ()
    {
        $this->setName("groupes");
        $this->setMethod("post");
        $this->addAttribs(
                array(
                        "class" => "cssform"
                ));
        
        $champ = new Zend_Form_Element_Hidden("id");
        $champs[] = $champ;
        
        $champ = new Zend_Form_Element_Text("nom");
        $champ->setLabel(__("Nom"));
        $champ->setRequired(true);
        $champs[] = $champ;
        
        $champ = new Jnd_Form_Element_Select("membres");
        $champ->setLabel(__("Membres"));
        $champ->setRequired(true);
        $champ->setRegisterInArrayValidator(false);
        $champ->setAttribs(
                array(
                        "class" => "multiselect",
                        "excludeSelectAll" => true,
                        "multiple" => true,
                        "chercherValeurDansLesCles" => false
                ));
        $champ->setMultiOptions($this->_utilisateurs);
        $champs[] = $champ;
        
        $champ = new Zend_Form_Element_Checkbox("protege");
        $champ->setLabel(__("Protégé"));
        $champ->setRequired(true);
        $champ->setCheckedValue("1");
        $champ->setUncheckedValue("0");
        $champs[] = $champ;
        
        $champ = new Zend_Form_Element_Select("idRole");
        $champ->setLabel(__("Role du groupe"));
        $champ->setMultiOptions($this->_roles);
        $champs[] = $champ;
        
        $champ = new Zend_Form_Element_Textarea("description");
        $champ->setLabel(__("Description"));
        $champs[] = $champ;
        
        $this->addElements($champs);
    }
}

